package com.dance.sharevalidator.validation.sequenceprovider;

import com.dance.sharevalidator.entity.Emp;
import org.hibernate.validator.spi.group.DefaultGroupSequenceProvider;

import java.util.ArrayList;
import java.util.List;

public class EmpGroupSequenceProvider implements DefaultGroupSequenceProvider<Emp> {
    @Override
    public List<Class<?>> getValidationGroups(Emp emp) {
        List<Class<?>> defaultGroupSequence = new ArrayList<>();
        defaultGroupSequence.add(Emp.class);
        if (emp != null) {
            if (emp.getAge() >= 20 && emp.getAge() < 25) {
                defaultGroupSequence.add(Emp.TitleJunior.class);
            }else if(emp.getAge() >= 25 && emp.getAge() < 30){
                defaultGroupSequence.add(Emp.TitleMiddle.class);
            }
        }
        return defaultGroupSequence;
    }
}
